package com.golxen.framework.redis;


import com.golxen.utils.StringUtils;

public class RedisServerOnlineCount {

    /**
     * 设置区服在线数量
     */
    public static void setOnlineCount(long serverId, long value){
        RedisManger.getRedisUtil().setString(RedisKeyDefine.SERVER_ONLINE_COUNT + ":" + serverId, value+"");
    }

    /**
     * 获取区服在线数量
     */
    public static long getOnlineCount(long serverId){
        String onlineCount = RedisManger.getRedisUtil().get(RedisKeyDefine.SERVER_ONLINE_COUNT + ":" + serverId);
        if(!StringUtils.isNullOrEmpty(onlineCount)){
            return Long.parseLong(onlineCount);
        }
        return 0;
    }
}
